
<!DOCTYPE HTML>
<html lang="en" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Common Bluetooth scale · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="ble_scale_custom_connect.html" />
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Overview
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../guide/android.html">
            
                <a href="../guide/android.html">
            
                    
                    android
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../guide/ios.html">
            
                <a href="../guide/ios.html">
            
                    
                    ios
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    work process
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.4.1" data-path="ble_scale.html">
            
                <a href="ble_scale.html">
            
                    
                    Common Bluetooth scale
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="ble_scale_custom_connect.html">
            
                <a href="ble_scale_custom_connect.html">
            
                    
                    Common Bluetooth Scale-Self-managed Bluetooth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="kitchen_scale.html">
            
                <a href="kitchen_scale.html">
            
                    
                    Kitchen scale
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="ble_user_scale.html">
            
                <a href="ble_user_scale.html">
            
                    
                    User Scale
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="ble_ruler.html">
            
                <a href="ble_ruler.html">
            
                    
                    Bluetooth ruler
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    API
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html">
            
                    
                    QNBleApi
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1.1" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#initsdk">
            
                    
                    initSdk
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.2" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#getcursystemblestate">
            
                    
                    getCurSystemBleState
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.3" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setsysblestatelistener">
            
                    
                    setSysBleStateListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.4" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setbledevicediscoverylistener">
            
                    
                    setBleDeviceDiscoveryListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.5" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setbleconnectionchangelistener">
            
                    
                    setBleConnectionChangeListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.6" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setdataListener">
            
                    
                    setDataListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.7" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setblekitchenlistener">
            
                    
                    setBleKitchenListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.8" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setloglistener">
            
                    
                    setLogListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.9" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#startbledevicediscovery">
            
                    
                    startBleDeviceDiscovery
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.10" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#stopbledevicediscovery">
            
                    
                    stopBleDeviceDiscovery
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.11" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#connectdevice">
            
                    
                    connectDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.12" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#connectuserscaledevice">
            
                    
                    connectUserScaleDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.13" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#connectblekitchendevice">
            
                    
                    connectBleKitchenDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.14" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setblekitchendeviceconfig">
            
                    
                    setBleKitchenDeviceConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.15" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#disconnectdevice">
            
                    
                    disconnectDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.16" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#getconfig">
            
                    
                    getConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.17" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#convertweightwithtargetunit">
            
                    
                    convertWeightWithTargetUnit
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.18" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#builddevice">
            
                    
                    buildDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.19" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#buildprotocolhandler">
            
                    
                    buildProtocolHandler
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.20" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#generatescaledata">
            
                    
                    generateScaleData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.21" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#physiquecalculation">
            
                    
                    physiqueCalculation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.22" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#switchuserscaleuser">
            
                    
                    switchUserScaleUser
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.23" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#updateuserscaleidentifyweight">
            
                    
                    updateUserScaleIdentifyWeight
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.24" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#setblerulerlistener">
            
                    
                    setBleRulerListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.25" data-path="../api/QNBleApi.html">
            
                <a href="../api/QNBleApi.html#connectrulerdevice">
            
                    
                    connectRulerDevice
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../api/QNUser.html">
            
                <a href="../api/QNUser.html">
            
                    
                    QNUser
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../api/QNScaleData.html">
            
                <a href="../api/QNScaleData.html">
            
                    
                    QNScaleData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../api/QNScaleStoreData.html">
            
                <a href="../api/QNScaleStoreData.html">
            
                    
                    QNScaleStoreData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../api/QNScaleItemData.html">
            
                <a href="../api/QNScaleItemData.html">
            
                    
                    QNScaleItemData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../api/QNBleDevice.html">
            
                <a href="../api/QNBleDevice.html">
            
                    
                    QNBleDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="../api/QNBleBroadcastDevice.html">
            
                <a href="../api/QNBleBroadcastDevice.html">
            
                    
                    QNBleBroadcastDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="../api/QNBleKitchenDevice.html">
            
                <a href="../api/QNBleKitchenDevice.html">
            
                    
                    QNBleKitchenDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.9" data-path="../api/QNConfig.html">
            
                <a href="../api/QNConfig.html">
            
                    
                    QNConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.10" data-path="../api/QNWiFiConfig.html">
            
                <a href="../api/QNWiFiConfig.html">
            
                    
                    QNWiFiConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.11" data-path="../api/QNUserScaleConfig.html">
            
                <a href="../api/QNUserScaleConfig.html">
            
                    
                    QNUserScaleConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.12" data-path="../api/QNBleKitchenConfig.html">
            
                <a href="../api/QNBleKitchenConfig.html">
            
                    
                    QNBleKitchenConfig
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.13" data-path="../api/QNBleStateListener.html">
            
                <a href="../api/QNBleStateListener.html">
            
                    
                    QNBleStateListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.14" data-path="../api/QNBleDeviceDiscoveryListener.html">
            
                <a href="../api/QNBleDeviceDiscoveryListener.html">
            
                    
                    QNBleDeviceDiscoveryListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.15" data-path="../api/QNBleConnectionChangeListener.html">
            
                <a href="../api/QNBleConnectionChangeListener.html">
            
                    
                    QNBleConnectionChangeListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.16" data-path="../api/QNScaleDataListener.html">
            
                <a href="../api/QNScaleDataListener.html">
            
                    
                    QNScaleDataListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.17" data-path="../api/QNUserScaleDataListener.html">
            
                <a href="../api/QNUserScaleDataListener.html">
            
                    
                    QNUserScaleDataListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.18" data-path="../api/QNBleKitchenListener.html">
            
                <a href="../api/QNBleKitchenListener.html">
            
                    
                    QNBleKitchenListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.19" data-path="../api/QNLogListener.html">
            
                <a href="../api/QNLogListener.html">
            
                    
                    QNLogListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.20" data-path="../api/QNResultCallback.html">
            
                <a href="../api/QNResultCallback.html">
            
                    
                    QNResultCallback
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.21" data-path="../api/QNShareData.html">
            
                <a href="../api/QNShareData.html">
            
                    
                    QNShareData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.22" data-path="../api/QNUtils.html">
            
                <a href="../api/QNUtils.html">
            
                    
                    QNUtils
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.23" data-path="../api/QNBleProtocolHandler.html">
            
                <a href="../api/QNBleProtocolHandler.html">
            
                    
                    QNBleProtocolHandler
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.24" data-path="../api/QNBleProtocolDelegate.html">
            
                <a href="../api/QNBleProtocolDelegate.html">
            
                    
                    QNBleProtocolDelegate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.25" data-path="../api/QNWspScaleDataListener.html">
            
                <a href="../api/QNWspScaleDataListener.html">
            
                    
                    QNWspScaleDataListener
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.26" data-path="../api/QNBleRulerDevice.html">
            
                <a href="../api/QNBleRulerDevice.html">
            
                    
                    QNBleRulerDevice
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.27" data-path="../api/QNBleRulerData.html">
            
                <a href="../api/QNBleRulerData.html">
            
                    
                    QNBleRulerData
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.28" data-path="../api/QNBleRulerListener.html">
            
                <a href="../api/QNBleRulerListener.html">
            
                    
                    QNBleRulerListener
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    Schedule
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../attouched_list/faq.html">
            
                <a href="../attouched_list/faq.html">
            
                    
                    FAQ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../attouched_list/body_indexes.html">
            
                <a href="../attouched_list/body_indexes.html">
            
                    
                    Body Index Constant
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../attouched_list/device_type.html">
            
                <a href="../attouched_list/device_type.html">
            
                    
                    Device Type
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../attouched_list/display_module_type.html">
            
                <a href="../attouched_list/display_module_type.html">
            
                    
                    Display module type
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../attouched_list/body_shape.html">
            
                <a href="../attouched_list/body_shape.html">
            
                    
                    Body shape comparison table
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../attouched_list/error_code.html">
            
                <a href="../attouched_list/error_code.html">
            
                    
                    Error Code
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../attouched_list/area_type.html">
            
                <a href="../attouched_list/area_type.html">
            
                    
                    Area Type
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../attouched_list/scan_error.html">
            
                <a href="../attouched_list/scan_error.html">
            
                    
                    Scan Error Code
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../attouched_list/scale_state.html">
            
                <a href="../attouched_list/scale_state.html">
            
                    
                    Scale State Definition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../attouched_list/scale_event.html">
            
                <a href="../attouched_list/scale_event.html">
            
                    
                    Scale event definition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="../attouched_list/test_list.html">
            
                <a href="../attouched_list/test_list.html">
            
                    
                    Test Case
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.12" data-path="../history/history.html">
            
                <a href="../history/history.html">
            
                    
                    Update Log
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Common Bluetooth scale</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="ordinary-bluetooth-scale">Ordinary Bluetooth scale</h1>
<p>The ordinary Bluetooth scale is the most common scale sold by our company. Its Bluetooth name is usually: <code>QN-Scale</code> or<code>QN-Scale1</code>. There is no difference in the use of these two Bluetooth name scales.</p>
<p>The workflow of the device is approximately as follows:</p>
<iframe src="https://mermaidjs.github.io/mermaid-live-editor/#/view/eyJjb2RlIjoic2VxdWVuY2VEaWFncmFtXG5cbnBhcnRpY2lwYW50IHVzZXIgYXMg55So5oi3XG5wYXJ0aWNpcGFudCBzY2FsZSBhcyDnp6Tnq69cbnBhcnRpY2lwYW50IGFwcCBhcyBBUFBcbnBhcnRpY2lwYW50IHNlcnZlciBhcyDkupHnq69cblxudXNlciAtPj4gYXBwOiDmiZPlvIBBUFBcbmFjdGl2YXRlIGFwcFxuYXBwIC0tPiBhcHA6IOWQr-WKqOaJq-aPj1xudXNlciAtPj4gc2NhbGU6IOi4qeS6ruenpFxuYWN0aXZhdGUgc2NhbGVcbnNjYWxlLS0-YXBwOiDlj5HpgIHok53niZnlub_mkq1cbmFwcC0tPmFwcDog5Yik5pat5piv5L2T6ISC56ek77yM5YGc5q2i5omr5o-PXG5hcHAtPj5zY2FsZTog5Y-R6LW36JOd54mZ6L-e5o6lXG5zY2FsZS0-PmFwcDog5ZCM5oSP6L-e5o6lXG5hcHAtLT5hcHA66L-e5o6l5oiQ5Yqf5bm25Yid5aeL5YyWXG5zY2FsZSAtLT5zY2FsZTog6L-e5o6l5oiQ5Yqf5bm25Yid5aeL5YyWXG5zY2FsZS0-PmFwcDog5Y-R6LW35o-h5omL5ZG95LukXG5hcHAtPj5zY2FsZTog5Zue5bqU5o-h5omL5ZG95LukXG5sb29wIOa1i-mHj-WunuaXtlxuc2NhbGUtLT5hcHA6IOensOmHjeWunuaXtuaVsOaNrlxuc2NhbGUtLT5hcHA6IOensOmHjeWunuaXtuaVsOaNrlxuZW5kXG51c2VyLS0-dXNlcjog56uZ56izXG5zY2FsZS0-PmFwcDog6YCa55-l5L2T6YeN56iz5a6aXG5zY2FsZS0tPnNjYWxlOua1i-mHj-mYu-aKl1xuc2NhbGUtPj5hcHA6IOWPkemAgemYu-aKl-aVsOaNrlxuYXBwLS0-YXBwOuiuoeeul-S9k-iEguaVsOaNrlxuc2NhbGUtLT5zY2FsZTog5rWL6YeP5b-D546H5pWw5o2uXG5zY2FsZS0-PmFwcDog5LiK5Lyg5b-D546H5pWw5o2uXG5kZWFjdGl2YXRlIHNjYWxlXG5hcHAtPj51c2VyOiDmmL7npLrlrozmlbTmtYvph4_nu5PmnpxcbmFwcC0-PiBzZXJ2ZXI6IOS4iuS8oOa1i-mHj-aVsOaNrlxuZGVhY3RpdmF0ZSBhcHBcbnVzZXItLT51c2VyOiDkuIvnp6Tlubbmn6XnnIvmlbDmja5cbiIsIm1lcm1haWQiOnsidGhlbWUiOiJkZWZhdWx0In19" frameborder="0" width="750" height="1080"></iframe>

<h2 id="one&#x3001;initialization">One&#x3001;initialization</h2>
<p>Use <a href="../api/QNBleApi.html#initsdk">QNBleApi.initSdk</a>-to-initialize,-there-are-related-introductions-in-the-previous-article,-<a href="../readme.md#development-process">please-check</a></p>
<h2 id="2-scanning">2. scanning</h2>
<h3 id="1-set-the-bluetooth-scan-callback-monitor-class">1. Set the Bluetooth scan callback monitor class</h3>
<p>Before scanning, you need to set the listener class. The method is <a href="../api/QNBleApi.html#setbledevicediscoverylistener">QNBleApi.setBleDeviceDiscoveryListener</a>. This method only needs to be called once. When you do not need to scan, remember to set to null/nil</p>
<p>android example:</p>
<pre><code class="lang-java">QNBleApi.getInstance(context).setBleDeviceDiscoveryListener(<span class="hljs-keyword">new</span> QNBleDeviceDiscoveryListener() {
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onDeviceDiscover</span><span class="hljs-params">(QNBleDevice device)</span> </span>{
<span class="hljs-comment">//This method calls back the device object, which can be processed by the device object</span>
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onStartScan</span><span class="hljs-params">()</span> </span>{
<span class="hljs-comment">//Back to start scanning</span>
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onStopScan</span><span class="hljs-params">()</span> </span>{
<span class="hljs-comment">//return to the end of the scan</span>
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onScanFail</span><span class="hljs-params">(<span class="hljs-keyword">int</span> code)</span> </span>{
<span class="hljs-comment">//The callback for the scan failure will be returned with an error code. For details, please refer to the error code details page</span>
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onBroadcastDeviceDiscover</span><span class="hljs-params">(QNBleBroadcastDevice device)</span> </span>{
<span class="hljs-comment">//Data callback of the broadcast scale, where only the data of the broadcast scale will be called back</span>
    }
});
</code></pre>
<p>iOS example:</p>
<pre><code>//set proxy
QNBleApi *bleApi = [QNBleApi sharedBleApi];
bleApi.discoveryListener = self;

//Implement the proxy method
- (void)onDeviceDiscover:(QNBleDevice *)device {
//This method will call back after the device is found
}

- (void)onBroadcastDeviceDiscover:(QNBleBroadcastDevice *)device {
//Callback when receiving broadcast scale data, this method will only call back the broadcast scale data
}

- (void)onStopScan {
//Callback when scanning is stopped
}

- (void)onStartScan {
//Callback when starting scanning
}
</code></pre><h3 id="2-start-the-scan">2. Start the scan</h3>
<p>Confirm that Bluetooth is turned on, and Android needs to check the <code>location permission</code> and<code>location switch</code>. If you confirm that Bluetooth is turned on, the location permission is authorized, and the location service switch is turned on, you can start Bluetooth scanning</p>
<blockquote>
<p>After Android 6.0, targetSdkVersion&gt;= 23 App above, you need to obtain positioning permission for Bluetooth scanning, please check <a href="https://developer.android.com/guide/topics/connectivity/bluetooth-le" target="_blank">About</a>
The location service switch is not mandatory, but some phones do not turn on this switch, and the device cannot be scanned, which is related to each mobile phone system.</p>
<p>iOS13 system has added Bluetooth usage permission, you need to check whether there is usage permission, confirm that authorized and Bluetooth is turned on, start scanning</p>
</blockquote>
<p>The scanning method is <a href="../api/QNBleApi.html#startbledevicediscovery">QNBleApi.startBleDeviceDiscovery</a>,-the-scanned-device-data-will-be-called-back-in-the-<a href="../api/qnbledevicediscoverylistener.md">qnbledevicediscoverylistener</a> in the scanning interface set above.</p>
<p>In addition, some feature settings related to scanning can be set in <a href="../api/QNConfig.html">QNConfig</a>, and the content to be set has been basically covered.</p>
<blockquote>
<p>Usually APP will have an interface dedicated to measurement. We generally perform Bluetooth scanning after the interface is displayed, and stop scanning when the interface disappears.</p>
</blockquote>
<p>android example:</p>
<pre><code class="lang-java">QNBleApi.getInstance(context).startBleDeviceDiscovery(<span class="hljs-keyword">new</span> QNResultCallback() {
            <span class="hljs-meta">@Override</span>
            <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onResult</span><span class="hljs-params">(<span class="hljs-keyword">int</span> code, String msg)</span> </span>{
<span class="hljs-comment">//This method does not return to the device, but indicates whether the scan was started successfully</span>
                <span class="hljs-keyword">if</span> (code != CheckStatus.OK.getCode()) {
                   ToastMaker.show(ScanActivity.<span class="hljs-keyword">this</span>,code+<span class="hljs-string">&quot;:&quot;</span>+msg);
                }
            }
        });
</code></pre>
<p>iOS example:</p>
<pre><code>//start scan
[[QNBleApi sharedBleApi] startBleDeviceDiscovery:^(NSError *error) {
//The callback here indicates whether the scan method is successfully started
    if (error) {
        NSLog([NSString stringWithFormat:@&quot;Failed to start scanning method, reason: %@&quot;,error]);
    }
}];
</code></pre><h2 id="three&#x3001;connection">three&#x3001;connection</h2>
<p>After receiving the callback device, you can determine whether it is a device that needs to be connected (this is the business logic of APP), and if so, connect it.</p>
<p>Before connecting, you need to set the connection status callback and measurement data callback.</p>
<p>The method for setting the connection status callback is: <a href="../api/QNBleApi.html#setbleconnectionchangelistener">QNBleApi.setBleConnectionChangeListener</a>, this method is the same as setting the scan callback method, multiple connections only need to be set once, if it is determined that no longer need to connect Time, set to null/nil</p>
<p>android example:</p>
<pre><code class="lang-java">QNBleApi.getInstance(context).setBleConnectionChangeListener(<span class="hljs-keyword">new</span> QNBleConnectionChangeListener() {
<span class="hljs-comment">//connecting</span>
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onConnecting</span><span class="hljs-params">(QNBleDevice device)</span> </span>{
        setBleStatus(QNScaleStatus.STATE_CONNECTING);
    }
<span class="hljs-comment">//connected</span>
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onConnected</span><span class="hljs-params">(QNBleDevice device)</span> </span>{
        setBleStatus(QNScaleStatus.STATE_CONNECTED);
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onServiceSearchComplete</span><span class="hljs-params">(QNBleDevice device)</span> </span>{
<span class="hljs-comment">//This state is the method after the search service is completed, usually this method does not require business logic</span>
    }

<span class="hljs-comment">//Disconnecting, when calling disconnect, it will call back immediately</span>
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onDisconnecting</span><span class="hljs-params">(QNBleDevice device)</span> </span>{
        setBleStatus(QNScaleStatus.STATE_DISCONNECTING);
    }

<span class="hljs-comment">//Disconnect, callback after disconnect</span>
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onDisconnected</span><span class="hljs-params">(QNBleDevice device)</span> </span>{
        setBleStatus(QNScaleStatus.STATE_DISCONNECTED);
    }

<span class="hljs-comment">//A connection error has occurred, please refer to the attached table for the error code</span>
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onConnectError</span><span class="hljs-params">(QNBleDevice device, <span class="hljs-keyword">int</span> errorCode)</span> </span>{
        setBleStatus(QNScaleStatus.STATE_DISCONNECTED);
    }
});
</code></pre>
<p>iOS example:</p>
<pre><code>- (void)onConnecting:(QNBleDevice *)device {
//callback to start connection
}

- (void)onConnected:(QNBleDevice *)device {
//callback for successful connection
}

- (void)onServiceSearchComplete:(QNBleDevice *)device {
//Callback for service completion
}

- (void)onDisconnecting:(QNBleDevice *)device {
//Disconnecting callback
}

- (void)onConnectError:(QNBleDevice *)device error:(NSError *)error {
//callback for connection failure
}
</code></pre><p>After setting the Bluetooth status callback, you also need to set the callback interface of the measurement data. The method is: <a href="../api/QNBleApi.html#setdatalistener">QNBleApi.setDataListener</a>, which can also be set once, please set it when it is no longer used Null/nil</p>
<p>android example:</p>
<pre><code class="lang-java">QNBleApi.getInstance(context).setDataListener(<span class="hljs-keyword">new</span> QNScaleDataListener() {
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onGetUnsteadyWeight</span><span class="hljs-params">(QNBleDevice device, <span class="hljs-keyword">double</span> weight)</span> </span>{
<span class="hljs-comment">//This method received unstable weight data. During one measurement, this method will call back multiple times until the data is stable and complete data is obtained.</span>
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onGetScaleData</span><span class="hljs-params">(QNBleDevice device, QNScaleData data)</span> </span>{
<span class="hljs-comment">//The method is to receive the complete measurement data</span>
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onGetStoredScale</span><span class="hljs-params">(QNBleDevice device, List&lt;QNScaleStoreData&gt; storedDataList)</span> </span>{
<span class="hljs-comment">//This method is to receive the stored data on the scale side, the processing method of the stored data can refer to the demo, or you can define it yourself</span>
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onGetElectric</span><span class="hljs-params">(QNBleDevice device, <span class="hljs-keyword">int</span> electric)</span> </span>{
<span class="hljs-comment">//This is the percentage of electricity obtained, only the electricity obtained by the charging scale is meaningful</span>
    }

<span class="hljs-comment">//Connection status during measurement</span>
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onScaleStateChange</span><span class="hljs-params">(QNBleDevice device, <span class="hljs-keyword">int</span> status)</span> </span>{
        setBleStatus(status);
    }
});
</code></pre>
<p>iOS example:</p>
<pre><code>- (void)onGetUnsteadyWeight:(QNBleDevice *)device weight:(double)weight {
//This method received unstable weight data. During one measurement, the method will call back multiple times until the data is stable and complete data is obtained
}

- (void)onGetScaleData:(QNBleDevice *)device data:(QNScaleData *)scaleData {
//The method is to receive the complete measurement data
}

- (void)onGetStoredScale:(QNBleDevice *)device data:(NSArray &lt;QNScaleStoreData *&gt; *)storedDataList {
//This method is to receive the stored data on the scale side, the processing method of the stored data can refer to the demo, or you can define it yourself
}

- (void)onGetElectric:(NSUInteger)electric device:(QNBleDevice *)device {
//This is the percentage of electricity obtained, only the electricity obtained by the charging scale is meaningful
}

- (void)onScaleStateChange:(QNBleDevice *)device scaleState:(QNScaleState)state {
//Connection status during measurement
}
</code></pre><p>In addition, before calling the connection, it is best to stop the previous scan (we found that some mobile phones have Bluetooth scanning and Bluetooth connection at the same time, which will reduce the failure rate of successful connection). After stopping the scan, delaying the call for 200 ~ 500ms before calling the connection will increase the success rate of the connection.
The method to stop Bluetooth scanning is: <a href="../api/QNBleApi.html#stopbledevicediscovery">QNBleApi.stopBleDeviceDiscovery</a>.</p>
<p>android example:</p>
<pre><code class="lang-java">QNBleApi.getInstance(context).stopBleDeviceDiscovery(<span class="hljs-keyword">new</span> QNResultCallback() {
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onResult</span><span class="hljs-params">(<span class="hljs-keyword">int</span> code, String msg)</span> </span>{
        <span class="hljs-keyword">if</span> (code == CheckStatus.OK.getCode()) {
            isScanning = <span class="hljs-keyword">false</span>;
        }
    }
});
</code></pre>
<p>iOS example:</p>
<pre><code>[[QNBleApi sharedBleApi] stopBleDeviceDiscovery:^(NSError *error) {
//The callback here indicates whether the method to stop scanning is successful
    if (error) {
        NSLog([NSString stringWithFormat:@&quot;Failed to stop scanning method, reason: %@&quot;,error]);
    }
}];
</code></pre><p>The method of connecting the device needs to pass the Yolanda Bluetooth device object (<a href="../api/QNBleDevice.html">QNBleDevice</a>) and the Yolanda user profile object (<a href="../api/QNUser.html">QNUser</a>), where <a href="../api/QNBleDevice.html">QNBleDevice</a><a href="../api/QNUser.html">QNUser</a> is created as: <a href="../api/QNBleApi.html#builduser">QNBleApi.buildUser</a>, the specific method of use can be Refer to the method description.</p>
<p>After confirming OK in the previous operation, you can finally connect. The connection method is: <a href="../api/QNBleApi.html#connectdevice">QNBleApi.connectDevice</a>.-the-connection-status-callback-method-is-the-above-<a href="../api/qnbleconnectionchangelistener.md">qnbleconnectionchangelistener</a></p>
<p>android example:</p>
<pre><code class="lang-java">QNBleApi.getInstance(context).connectDevice(device, user, <span class="hljs-keyword">new</span> QNResultCallback() {
                <span class="hljs-meta">@Override</span>
                <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onResult</span><span class="hljs-params">(<span class="hljs-keyword">int</span> code, String msg)</span> </span>{
<span class="hljs-comment">//This method is just a method to adjust whether the connection method is successful</span>
                }
            });
</code></pre>
<p>iOS example:</p>
<pre><code>[[QNBleApi sharedBleApi] connectDevice:device user:user callback:^(NSError *error) {
//The callback here indicates whether the call to the connection method was successful
    if (error) {
        NSLog([NSString stringWithFormat:@&quot;Failed to call connection method, reason: %@&quot;,error]);
    }  
}];
</code></pre><h2 id="weighing-process">Weighing process</h2>
<p>The data and status of the weighing process will be recalled in the above-mentioned <a href="../api/QNScaleDataListener.html">QNScaleDataListener</a></p>
<h2 id="end-of-measurement">End of measurement</h2>
<p>After receiving stable data (that is, <a href="../api/QNScaleDataListener.html#ongetscalesata">QNScaleDataListener.onGetScaleData</a>),-the-measurement-is-completed.-at-this-time,-the-scale-will-not-disconnect-bluetooth-immediately,-but-will-wait-for-a-short-time-(may-be-2-minutes)-before-the-scale-is-closed.-if-you-need-to-disconnect-as-soon-as-possible,-you-can-call-the-method-<a href="../api/qnbleapi.md#disconnectdevice">qnbleapi.disconnectdevice</a> with a delay of 2s after receiving stable data to disconnect the device.</p>
<p>At this point, the basic process of the ordinary Bluetooth scale has been completed, the APP can save the data and display the data by itself after receiving the stable data. Data standards can be judged by our company-<a href="../attouched_list/SDK%20indicator%20standard%20description.pdf">SDK indicator standard description</a>.</p>
<p>For other questions, please refer to the code in the Demo first. If you have any questions, you can also check <a href="../attouched_list/faq.html">FAQ</a> Common problems have not found related problems, you can try to search in the SDK if there are related APIs or instructions, if not, please contact our technical staff for assistance.</p>
<p>Demo address is as follows:
<a href="https://github.com/YolandaQingniu/sdk-ios-demo.git" target="_blank">iOSDemo</a></p>
<p><a href="https://github.com/YolandaQingniu/qnscalesdkX.git" target="_blank">AndroidDemo</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="ble_scale_custom_connect.html" class="navigation navigation-next navigation-unique" aria-label="Next page: Common Bluetooth Scale-Self-managed Bluetooth">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Common Bluetooth scale","level":"1.4.1","depth":2,"next":{"title":"Common Bluetooth Scale-Self-managed Bluetooth","level":"1.4.2","depth":2,"path":"flow/ble_scale_custom_connect.md","ref":"flow/ble_scale_custom_connect.md","articles":[]},"previous":{"title":"work process","level":"1.4","depth":1,"ref":"","articles":[{"title":"Common Bluetooth scale","level":"1.4.1","depth":2,"path":"flow/ble_scale.md","ref":"flow/ble_scale.md","articles":[]},{"title":"Common Bluetooth Scale-Self-managed Bluetooth","level":"1.4.2","depth":2,"path":"flow/ble_scale_custom_connect.md","ref":"flow/ble_scale_custom_connect.md","articles":[]},{"title":"Kitchen scale","level":"1.4.3","depth":2,"path":"flow/kitchen_scale.md","ref":"flow/kitchen_scale.md","articles":[]},{"title":"User Scale","level":"1.4.4","depth":2,"path":"flow/ble_user_scale.md","ref":"flow/ble_user_scale.md","articles":[]},{"title":"Bluetooth ruler","level":"1.4.5","depth":2,"path":"flow/ble_ruler.md","ref":"flow/ble_ruler.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["mermaid-gb3"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"mermaid-gb3":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"en","gitbook":"*"},"file":{"path":"flow/ble_scale.md","mtime":"2022-03-01T12:53:11.319Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-01-16T11:02:39.181Z"},"basePath":"..","book":{"language":"en"}});
        });
    </script>
</div>

        
    
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

